#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@File    :   test2.py
@Time    :   2024/08/23 15:02:27
@Author  :   Rico Chen 
@Mail    :   55059@qq.com
@Version :   1.0
@Desc    :   测试数据响应式编程，不用事件驱动，用数据驱动
"""


from nicegui import ui
from ex4nicegui import rxui, to_ref

# ref data
names = ["Tab 1", "Tab 2", "Tab 3"]
current_tab = to_ref(names[0])

# function
with rxui.tabs(current_tab):
    for name in names:
        rxui.tab(name)

with rxui.tab_panels(current_tab):
    for name in names:
        with rxui.tab_panel(name):
            ui.label(f"Content of {name}")

# ui
ui.label("Welcome to NiceGUI!")
ui.button("Click Here", on_click=lambda: ui.notify("Button Pressed"))

ui.run()
